package study.readFiles;

import java.io.*;

public class ReadFiles {
    public static void main(String[] args) {
        try {
            BufferedReader in = new BufferedReader(new FileReader("src/main/java/study/readFiles/huan-rules.json"));
            while (in.ready()) {
                System.out.println(in.readLine());
            }
            File file = new File("ab.txt");
            if(!file.exists()){
                file.createNewFile();
            }
            FileWriter fileWriter = new FileWriter(file,true);
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            bufferedWriter.write("zheshi buffwrite");
            fileWriter.write("heheda");
            fileWriter.write("\nheheda???");
            System.out.println("写入成功");
            fileWriter.close();
            bufferedWriter.close();
            BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
            while (bufferedReader.ready()) {
                System.out.println(bufferedReader.readLine());
            }
            in.close();
        } catch (IOException ignored) {
        }
    }
}
